home *** CD-ROM | disk | FTP | other *** search
/ The Fatted Calf / The Fatted Calf.iso / Applications / Scheduling / Cassandra / Source / voice / voice.c
Encoding:
C/C++ Source or Header  |  1990-06-10  |  1.5 KB  |  91 lines

  1. #import <stdio.h>
  2. #import <libc.h>
  3. #import <ctype.h>
  4. #import <strings.h>
  5. #define SNDPLAY    "/usr/bin/sndplay "
  6. void voice( char *message, char *wordSouce);
  7. void number( char *buf, char *systemBuf);
  8.  
  9.  
  10. void
  11. main()
  12. {
  13. char string[300];
  14.  
  15.     gets(string);
  16.     voice( string, "/user/jiro/Library/Sounds");
  17.     return;
  18. }
  19.  
  20.  
  21. void
  22. voice( char *message, char *wordSource)
  23. {
  24. char *index;
  25. char buf[128], *bufIndex;
  26. char buf2[1000];
  27. char systemBuf[1000];
  28.  
  29. if( *message == '\0')    // if we got a null string;
  30.     return;        // return
  31.  
  32. index = message;
  33. bufIndex = buf;
  34.  
  35. for( index = message; *(index-1) != '\0'; index ++)
  36.     {
  37.     *bufIndex = *index;
  38.     if( isupper(*bufIndex))
  39.         *bufIndex = tolower(*bufIndex);
  40.  
  41.     if( *index == ' ' || *index == '\0')
  42.         {
  43.         *bufIndex = '\0';
  44.  
  45.         if( isdigit( *buf))
  46.             number( buf, systemBuf);
  47.         else
  48.             {
  49.             fprintf(stderr,"Buf is <%s>.\n", buf);
  50.             sprintf(buf2, " %s.snd",buf);
  51.             strcat(systemBuf, buf2);
  52.             }
  53.         fprintf(stderr,"Parsing: -> %s\n", systemBuf);
  54.         bufIndex = buf;
  55.         continue;
  56.         }
  57.     bufIndex ++;
  58.     }
  59.  
  60. chdir( wordSource);
  61. sprintf(buf2, "%s %s", SNDPLAY, systemBuf);
  62. fprintf(stderr,"Playing: -> %s\n", buf2);
  63. system(buf2);
  64. return;
  65. }
  66.  
  67.  
  68. void
  69. number(char *buf, char *systemBuf)
  70. {
  71. int number, temp;
  72. char *digits[16] = {     " zero.snd", " one.snd"," two.snd", " three.snd",
  73.             " four.snd", " five.snd", " six.snd", " seven.snd",
  74.             " eight.snd", " nine.snd", " ten.snd",
  75.             " eleven.snd", " twelve.snd",
  76.             " thirteen.snd", " fourteen.snd",
  77.             " fifteen.snd"};
  78.  
  79.     
  80.     number = atoi(buf);
  81.  
  82.     if( number > 0 && number < 20)
  83.         strcat(systemBuf, digits[number]);
  84.     
  85.     return;
  86. }
  87.  
  88.             
  89.  
  90.  
  91.